from eim import db
from eim.DataBasModals.mode import TblUserinfo
from eim.result.simple_result import SimpleResult
from flask import current_app


class SchedulerService:
    def __init__(self):
        dbcon = db.engine.connect()
        tableName = TblUserinfo

    # 解锁所有操作员的用户锁定状态
    def unlockAllUser(self):
        """
        解锁所有操作员的用户锁定状态
        :return:
        """
        try:
            uv = {"status": "00"}
            return self.updateData(uv)
        except Exception as err:
            current_app.logger.error(f"{str(err)}")
            return SimpleResult(msg=f"解锁过程出现异常,{str(err)}", value=500).toDict()

    # 更新最后通讯时间
    def updateLastTime(self, uv: dict):
        """
        更新最后同步时间
        :param uv: 更新条件
        :return: 返回更新状态
        """
        try:
            return self.updateData(uv)
        except Exception as err:
            current_app.logger.error(f"{str(err)}")
            return SimpleResult(msg=f"解锁过程出现异常,{str(err)}", value=500).toDict()
